package com.example.demo;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.core.parser.ISqlParser;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import com.baomidou.mybatisplus.extension.plugins.SqlExplainInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

@MapperScan("com.example.demo.core.mapper")
@SpringBootApplication
public class SpringBootMybatisPlusApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringBootMybatisPlusApplication.class, args);
	}


	/**
	 * 分页插件
	 */
	@Bean
	public PaginationInterceptor paginationInterceptor() {
		return new PaginationInterceptor();
	}

	/**
	 * 逻辑删除
	 */
//	@Bean
//	public ISqlInjector sqlInjector() {return new LogicSqlInjector();}
//
//	@Bean
//	public SqlExplainInterceptor sqlExplainInterceptor(){
//		SqlExplainInterceptor sqlExplainInterceptor = new SqlExplainInterceptor();
//		List<ISqlParser> sqlParserList = new ArrayList<>();
//		sqlParserList.add(new BlockAttackSqlParser());
//		sqlExplainInterceptor.setSqlParserList(sqlParserList);
//		return sqlExplainInterceptor;
//	}
	@Bean
	public PerformanceInterceptor performanceInterceptor(){
		//启用性能分析插件
		return new PerformanceInterceptor();
	}
}

